package cn.fj.hrm.fallback;

import cn.fj.hrm.basic.util.JsonResult;
import cn.fj.hrm.client.MsgSenderClient;
import cn.fj.hrm.domain.Msg;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MsgSenderClientFallbackFactory implements FallbackFactory<MsgSenderClient> {
    @Override
    public MsgSenderClient create(Throwable throwable) {
        return new MsgSenderClient() {
            @Override
            public JsonResult sendMsg(Msg msg) {
                throwable.printStackTrace();
                return JsonResult.me().setSuccess(false).setMsg("消息推送服务接口sendMsg调用失败：" + throwable.getMessage());
            }
        };
    }
}
